<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col>
            <a-form-model-item label='年级' prop='queryParam.gradeId'>
              <s-dict-select-tag @change='changeTest' v-model='queryParam.gradeId' placeholder='请选择年级'
                                 dictCode='cou_grade,grade_name,id,tenant_id  is not null order by  grade_order' />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter='24'>
          <a-col :xl='4' :lg='10' :md='100' :sm='80'>
            <a-form-item label='老师姓名'>
              <a-input placeholder='请填写老师姓名' v-model.trim='queryParam.teacherName'></a-input>
            </a-form-item>
          </a-col>
          <a-col :span='5'>
            <a-form-model-item layout='inline' label='开始日期' prop='jDate'>
              <j-date v-model='queryParam.startDate' :showTime='true' dateFormat='YYYY-MM-DD' />
            </a-form-model-item>
          </a-col>
          <a-col :span='5'>
            <a-form-model-item label='截止日期' prop='jDate'>
              <j-date v-model='queryParam.endDate' :showTime='true' dateFormat='YYYY-MM-DD' />
            </a-form-model-item>
          </a-col>

          <!--          <a-col :xl='9' :lg='7' :md='8' :sm='24'>-->
          <!--          <template>-->
          <!--            <a-form :form="form">-->
          <!--              <a-form-item label="选择老师" style="width: 500px">-->
          <!--                <j-select-multi-teacher :multi=false   v-model="teachers" ></j-select-multi-teacher>-->
          <!--              </a-form-item>-->
          <!--            </a-form >-->
          <!--          </template>-->
          <!--          </a-col>-->
        </a-row>
        <a-row :gutter='24'>
          <a-col :offset='8'>
            <span style='overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
              <!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
              <!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />-->
              <!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class='table-operator'>
      <a-form layout='inline'>

      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <!--      <a-button type='primary' icon='download' @click="handleExportXls('课时统计(年月)')">导出</a-button>-->

      <a-table
        id="datatable"
        ref='table'
        size='middle'
        :scroll='{x:true}'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        class='j-table-force-nowrap'
        @change='handleTableChange'>

        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' height='25px' alt=''
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            type='primary'
            icon='download'
            size='small'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>

        <span slot='action' slot-scope='text, record'>
<!--          <a @click="handleEdit(record)">编辑</a>-->

          <!--          <a-divider type="vertical" />-->
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
<!--              <a-menu-item>-->
              <!--                <a @click="handleDetail(record)">详情</a>-->
              <!--              </a-menu-item>-->
              <a-menu-item>
<!--&lt;!&ndash;                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">&ndash;&gt;-->
                <!--&lt;!&ndash;                  <a>删除</a>&ndash;&gt;-->
                <!--                </a-popconfirm>-->
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <rel-class-student-modal ref='modalForm' @ok='modalFormOk'></rel-class-student-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, postAction } from '@api/manage'
import JSelectMultiTeacher from '../components/public/JSelectMultiTeacher'
import JDate from '@/components/jeecg/JDate'

export default {
  name: 'CouTeachingJobExecuteDateList',
  components: { JSelectMultiTeacher, JDate },
  mixins: [JeecgListMixin, mixinDevice],
  data() {
    return {
      description: '老师课时按年月统计',
      whereData: [
        { dateType: '%Y-%m', value: '学月', types: 'primary' },
        { dateType: '%Y', value: '学年', types: '' }
      ],
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '年级名称',
          align: 'center',
          dataIndex: 'gradeName'
        },
        {
          title: '老师名称',
          align: 'center',
          dataIndex: 'teacherName'
        },
        {
          title: '总课时量',
          align: 'center',
          dataIndex: '总课时量',
        },
        {
          title: '正常课时',
          align: 'center',
          dataIndex: '正常'
        },
        {
          title: '代入课时',
          align: 'center',
          dataIndex: '代入课'
        }
      ],
      url: {
        queryTeacherJobDurationDate: '/couteachingjobexecute/couTeachingJobExecute/queryTeacherJobDurationDate',
        exportXlsUrl: '/couteachingjobexecute/couTeachingJobExecute/exportXls'
      },
      tableData: [],
      dictOptions: {},
      superFieldList: [],
      dataSource: [],
      startDate: '',
      endDate: '',
      dateType: '%Y-%m',
      teachers: ''
    }
  },
  created() {
    this.getSuperFieldList()
    // this.test()
  }
  ,
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  }
  ,
  methods: {
    loadData() {
      this.queryTeacherJobDurationDate()

    }
    ,
    onSetDate(obj) {
      this.dateType = obj.dateType
      this.whereData.forEach(item => {
        item.types = ''
      })
      obj.types = 'primary'
      this.queryTeacherJobDurationDate()
    }
    ,
    queryTeacherJobDurationDate() {
      if (!this.queryParam.gradeId) {
        this.$message.success('请选择年级信息！')
        return
      }
      var params = this.getQueryParams()
      //this.$set(params,'dataType',this.dateType); 添加响应式属性
      // 添加多个响应式属性
      // this.params = Object.assign({},this.params,{
      //   dataType:this.dateType
      // })
      getAction(this.url.queryTeacherJobDurationDate, params).then(res => {
        if (res.success) {
          this.dataSource = res.result.pageList.records
          if (res.result.pageList.total) {
            this.ipagination.total = res.result.pageList.total
          } else {
            this.ipagination.total = 0
          }
        } else {
          this.$message.error(res.message)
        }
      })
    }
    ,
    initDictConfig() {
    }
    ,
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'classCode', text: '班级code' })
      fieldList.push({ type: 'string', value: 'studentCode', text: '学生code' })
      fieldList.push({ type: 'string', value: 'tenantId', text: '学校code' })
      fieldList.push({ type: 'int', value: 'classStudentStatus', text: '有效状态' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>